package ${package.Controller};

import ${package.Entity}.${entity};
import ${package.Service}.${table.serviceName};
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.Valid;
import java.util.List;
import com.common.res.DataResult;
<#if restControllerStyle>
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>


import javax.validation.Valid;
import java.util.List;

/**
* @author ${author}
* @since ${date}
*/
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("api")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
 <#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
 <#else>
public class ${table.controllerName} {
 </#if>

    @Autowired
    private ${table.serviceName} ${table.serviceName?uncap_first};

    @GetMapping("/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
    @RequiresPermissions("sys:${table.entityName?uncap_first}:list")
    public DataResult<List<${table.entityName}>> getAllDept(${table.entityName} ${table.entityName?uncap_first}){
        DataResult result =DataResult.success();

        return result;
    }

    @PostMapping("/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
    @RequiresPermissions("sys:${table.entityName?uncap_first}:add")
    public DataResult add(@Valid @RequestBody ${table.entityName} ${table.entityName?uncap_first}) {
        DataResult result =DataResult.success();

        return result;
    }

    @PutMapping("/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
    @RequiresPermissions("sys:${table.entityName?uncap_first}:update")
    public DataResult update(@Valid @RequestBody ${table.entityName} ${table.entityName?uncap_first}) {
        DataResult result =DataResult.success();

        return result;
    }


    @DeleteMapping(value = "/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>/{ids}")
    @RequiresPermissions("sys:${table.entityName?uncap_first}:delete")
    public DataResult remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        DataResult result =DataResult.success();

        return result;
    }
}
</#if>